using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SPSolutions.Samples.PickerApp.WebControls
{
    /// <summary>
    /// Represents a site picker dialog box
    /// </summary>
    public class CityPickerDialog : PickerDialog
    {
        /// <summary>
        /// Editor control
        /// </summary>
        public new CityEditor EditorControl
        {
            get { return (CityEditor)base.EditorControl; }
        }

        /// <summary>
        /// Get requested state
        /// </summary>
        public string RequestedState
        {
            get
            {
                if (string.IsNullOrEmpty(Page.Request.QueryString["State"]))
                {
                    return "TN";
                }
                return Page.Request.QueryString["State"];
            }
        }

        /// <summary>
        /// Default constructor
        /// </summary>
        public CityPickerDialog()
            : base(new CityQueryControl(), new TableResultControl(), new CityEditor())
        {
            // Create a list of column display names
            ArrayList columnDisplayNames = ResultControl.ColumnDisplayNames;
            columnDisplayNames.Clear();
            columnDisplayNames.Add("City Name");
            columnDisplayNames.Add("State");

            // Create a list of column names
            ArrayList columnNames = ResultControl.ColumnNames;
            columnNames.Clear();
            columnNames.Add(CityEditor.CityInfo.Title);
            columnNames.Add(CityEditor.CityInfo.State);

            // Create a list of column widths
            ArrayList columnWidths = ResultControl.ColumnWidths;
            columnWidths.Clear();
            columnWidths.Add("30%");
            columnWidths.Add("70%");
        }

        /// <summary>
        /// Result control
        /// </summary>
        public new TableResultControl ResultControl
        {
            get { return (TableResultControl)base.ResultControl; }
        }

        /// <summary>
        /// Load method
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            base.DialogTitle = "City Picker";
            base.Description = "Please select a city";
        }
    }
}
